package at.ac.tuwien.prog.view;

import java.awt.Color;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;

/**
 * 
 * @author christoph.pickl@student.tuwien.ac.at
 */
public class DataTable extends JTable {
	
	private static final long serialVersionUID = 8200660711096387133L;

	private static final int CELL_SIZE = 20;
	
	public DataTable(final TableModel model) {
		super(model);
		
		this.setRowSelectionAllowed(false);
		this.setTableHeader(null);
		
		this.setGridColor(new Color(30, 30, 30));
		
		this.setRowHeight(CELL_SIZE);
		 
		final TableColumnModel modelx = this.getColumnModel();
		for (int i = 0; i < modelx.getColumnCount(); i++) { 
			TableColumn column = modelx.getColumn(i);
			column.setPreferredWidth(CELL_SIZE);
			
		}
		
	}
	
	@Override
	public TableCellRenderer getCellRenderer(final int row, final int col) {
		final TableCellRenderer superRenderer = super.getCellRenderer(row, col);
		
		final JLabel renderedLabel = (JLabel) superRenderer;
		
		renderedLabel.setHorizontalAlignment(SwingConstants.CENTER);
		renderedLabel.setBackground(Color.BLACK);
		renderedLabel.setForeground(Color.GREEN);
		
		return superRenderer;
	}
	
}
